<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\OrderHistory;

class StayController extends Controller
{
       // 检测用户是否登录，无登录跳转到登录页面
    public function __construct()
    {
       $this->middleware('auth');
    }
    //未付款订单列表
    public function index(){

    	//取出订单
		$order = OrderHistory::where('order_status','待付款')
								->LeftJoin('serves','order_histories.sid','=','serves.id')
								->select('order_histories.*','serves.title','serves.commit','serves.path')
								->OrderBy('id','desc')->paginate(5);

    	return view('staticpages.order.staty',compact('order'));
    }

    //订单详情页
    public function edit($id){

    	//取出订单详情
    	$order = OrderHistory::where('order_histories.id',$id)
    					->LeftJoin('users','order_histories.mobile','=','users.phone')
    					->LeftJoin('serves','order_histories.sid','=','serves.id')
    					->select('order_histories.*','users.name','serves.*')
    					->first();

    	return view('staticpages.order.statylist',compact('order'));
    }
}
